package com.ftg.learn.chapter09.listtest;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

/**
 * 查找List中特定元素的索引
 *
 * @author lijiaxin
 * @version 1.0
 * @date 2023/8/16 10:55
 */

public class index {

    public static void main(String[] args) {

        List<String> list= Arrays.asList("we","rt","oo");
        System.out.println(list);
        int index=0;
        System.out.println("输入查找的元素");
        Scanner scanner=new Scanner(System.in);
        String str=scanner.next();
        for (int i = 0; i < list.size(); i++) {
            if(list.get(i).equals(str)){
                System.out.println("此元素的下标为："+ index);
            } else {
                System.out.println("此元素不存在");
                continue;
            }
            index++;
        }
    }
}
